<?php
namespace app\admin\controller;

use think\App;
use think\facade\View;
use think\facade\Db;

class Kefu extends BaseController
{
    public function lists()
    {
        $list = Db::name('kefu')
            ->alias('k')
            ->leftJoin('kefu_category kc', 'k.category_id = kc.category_id')
            ->field('k.*, kc.category_name')
            ->select();
        foreach($list as $val){
            echo $val['username'] . ' ';
            echo $val['realname'] . ' ';
            echo $val['category_name'] . ' ';
            echo '</br>';
        }
    }

    public function add()
    {
        $data = [
            'username' => 'xiaozhao',
            'realname' => '赵雷',
            'password' => md5('123456'),
            'site_id' => 1,
            'category_id' => 2,
            'create_time' => time(),
        ];
        $res = Db::name('kefu')->save($data);
        dump($data);
        dump($res);
    }
}
